package Born.loader
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import novesfora.events.Events;

	public class LoadXML extends MovieClip
	{
		private var $xmlFile					:String;
		private var $xmlLoader					:URLLoader;
		private var $xml						:XML;
		
		public function LoadXML(XMLFile:String)
		{
			$xmlFile = XMLFile;
			
			$xmlLoader = new URLLoader();
			$xmlLoader.load(new URLRequest($xmlFile));
			$xmlLoader.addEventListener(Event.COMPLETE, XMLComplete);
			$xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, XMLError);
			$xmlLoader.addEventListener(ProgressEvent.PROGRESS, XMLProgress);
		}
		
		private function XMLComplete(e:Event):void
		{
			$xml = new XML(e.target.data);
			dispatchEvent(new Events(Events.COMPLETE,{ XML : $xml }));
		}
		
		private function XMLError(e:IOErrorEvent):void
		{
			dispatchEvent(new Events(Events.IOError, { Error:e.text } ));
		}
		
		private function XMLProgress(e:ProgressEvent):void
		{
			
		}
		
	} /** End Class */
	
} /** End Package */